home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / FLI106C.ZIP;1 / FLIWIN.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-12  |  16.2 KB  |  452 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.06c
  4. // Copyright (C) 1990, 1991, 1992
  5. // Software Dimensions
  6. //
  7. // Main Header File for window related classes, variables, and functions
  8. //
  9. // If you include this file, without including FLI.H first -- this file
  10. // will automatically include it for you
  11. //
  12.  
  13. // ==========================================================================
  14. // Consult the reference manual for complete function reference of all
  15. // functions within this header file.  All variables are documented
  16. // inside this header file, for ease of use when modifying the supplied
  17. // source code.  For additional class information, please consult the
  18. // Software Dimensions BBS.  Telephone numbers are included in the
  19. // READ.ME file and in the documentation.
  20. // ==========================================================================
  21.  
  22. #ifndef __FusionWindows__
  23. #define __FusionWindows__
  24.  
  25. #ifndef __Fusion__
  26. #include "fli.h"
  27. #endif
  28.  
  29. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
  30. //                                                                           //
  31. // ShiftManager - Controls the ctrl/alt/normal prompt line                   //
  32. //                                                                           //
  33. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
  34.  
  35. class WindowElement;
  36.  
  37. class ShiftManager : virtual public FusionHelp
  38. {
  39. private:
  40.  
  41.   int NumKeyTies;                   // Number of keys that are linked
  42.  
  43.   struct _HotKeys                   // Structure containing defined hot keys
  44.   {
  45.     int Tie;                          // The key code for the hot key
  46.     int Event;                        // The event that cooresponds to the key
  47.   } *Keys;
  48.  
  49.   struct _PromptLine                // Structure containing the prompt line
  50.   {
  51.     char *Key;                        // The text for the key
  52.     char *Info;                       // The text for the key description
  53.     int Event;                        // The event linked to this key
  54.   } *Alt, *Ctrl, *Normal;
  55.  
  56.   int NumAltKeys;                   // Number of defined ALT keys
  57.   int NumCtrlKeys;                  // Number of defined CTRL keys
  58.   int NumNormKeys;                  // Number of defined unshifted keys
  59.  
  60.   int InAWindow;                    // Are we in a window?
  61.  
  62.   int Item;                         // Current highlighted item (by mouse)
  63.   int XOffset;                      // X coordinate of highlighted item
  64.   int PromptWidth;                  // Width of highlighted item
  65.   int OnLastShift;                  // Item last shifted/highlighted
  66.  
  67.   char *SnapShot;                   // Snap shot of bottom display line
  68.  
  69. protected:
  70.                                     // These members are static because
  71.                                     // of the possibilities of multiple
  72.                                     // prompt lines accross windows and
  73.                                     // the problems they can pose if each
  74.                                     // shift manager doesn't know what
  75.                                     // happened with the shift states
  76.  
  77.   static int LastShift;             // Last state of the shifted keys
  78.   static int KeyLast;               // Last key pressed
  79.  
  80.   int RefreshPromptLine();
  81.   int CheckEvent(int);
  82.  
  83. public:
  84.  
  85.   ShiftManager();
  86.   ~ShiftManager();
  87.  
  88.   void DefineAltKey(char *,char *,int=0,int=0);
  89.   void DefineCtrlKey(char *,char *,int=0,int=0);
  90.   void DefineNormKey(char *,char *,int=0,int=0);
  91.   void DefineKey(int,int);
  92.  
  93.   int CheckPromptLine();
  94.  
  95.   virtual int EventHandler(int) = 0;
  96.  
  97.   friend class WindowElement;
  98. };
  99.  
  100. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
  101. //                                                                           //
  102. // MenuManager - The main menu control class [uses _Options and MenuItems]   //
  103. // _Options - Contains the menu options, which is used inside MenuItems      //
  104. // MenuItems - Contains information about each menu on the menu bar and      //
  105. //    self-contains the _Options structure which stores each menu item on    //
  106. //    the menu
  107. //                                                                           //
  108. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
  109.  
  110. class WindowElement;
  111. class FusionWindow;
  112. class MenuAlteration;
  113. class MenuItems;
  114.  
  115. struct _Options                     // structure containing menu options
  116. {
  117.   char *Help;                       // The help line for this option
  118.   char *Option;                     // The name of this option
  119.   char *HotKeyOption;               // The text for the hot key
  120.                                     // linked to this option
  121.  
  122.   int Event;                        // The event linked to this option
  123.   int HotKey;                       // The hot key linked to this option
  124.   int QuickKey;                     // The one-key quick-key for this option
  125.   int SelectCount;                  // Number of available selectables
  126.   int WidestSelectable;             // What is the width of the widest?
  127.   int *Available;                   // Pointer to integer signifying if
  128.                                     // this option is available (1)
  129.   int *Checked;                     // Can this option be checked?
  130.   int *Selectable;                  // Current selectable option
  131.  
  132.   char **Selectables;               // List of selectable options
  133.  
  134.   MenuItems *SubMenu;               // Pointer to a sub menu, if available
  135.  
  136.   int PreviousState;                // Stores the previous state of the
  137.                                     // menu option -- the available state
  138. };
  139.  
  140. class MenuItems                     // Class containing menu items
  141. {
  142. private:
  143.  
  144.   _Options *Option;                 // Contains menu items
  145.  
  146.   char *Title;                      // Title of the menu on the menu bar
  147.   char *MenuHelp;                   // Global help for the menu
  148.  
  149.   int X;                            // X location of menu
  150.   int Y;                            // Y location of menu
  151.   int XEnd;                         // End of title on menu bar (for mouse)
  152.   int Width;                        // Width of the menu
  153.   int Height;                       // Height of the menu
  154.   int XStart;                       // Start of title on menu bar (for mouse)
  155.   int HotKeys;                      // Are hot keys available (1) or not (0)
  156.   int SubMenus;                     // Are sub menus available (1) or not (0)
  157.   int Checkables;                   // Are there any checkables (1) or not (0)
  158.   int MenuHotKey;                   // Hot key to activate this menu
  159.   int Selectables;                  // Are there any selectable options (1)?
  160.   int CurrentOption;                // Currently selected option on menu
  161.   int NumberOfOptions;              // Number of menu options available
  162.  
  163.   int MenuEvent;                    // Event for this menu
  164.  
  165.   char *SavedRegion;                // Storage for screen under the menu
  166.  
  167.   int ScanMenu(int);
  168.   int PlaceOption(int);
  169.   int PlaceMenu(int,int,MenuItems &,int=0);
  170.  
  171.   void RemoveMenu();
  172.   void RemoveOption();
  173.   void ReCheckOption();
  174.   void ReSelectOption();
  175.  
  176.   void _HotKey(char *,int);
  177.   void _Option(char *,char *,int=0,char *HotKey=0,int=0);
  178.  
  179. public:
  180.  
  181.   MenuItems();
  182.   ~MenuItems();
  183.  
  184.   friend class MenuManager;
  185.   friend class FusionWindow;
  186.   friend class MenuAlteration;
  187. };
  188.  
  189. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
  190. //                                                                           //
  191. // MenuManager - The main menu control class                                 //
  192. //                                                                           //
  193. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
  194.  
  195. class MenuManager : virtual public FusionHelp
  196. {
  197. public:
  198.  
  199.   MenuItems **Menus, **SubMenuTrack; // Defines menus and sub menus
  200.  
  201.   static int IsPullDown;            // Are menus pulldown (1) or popdown (0)
  202.   static int Beneath;               // Sub menus are displayed beneath (1)
  203.                                     // or to right of (0) menu options
  204.   static int IdentifyCheck;         // Should the underscore be shown?
  205.  
  206.   int SetX;                         // X location of menu bar
  207.   int SetY;                         // Y location of menu bar
  208.   int StowedWidth;                  // Current Width of Bar (for menu altering)
  209.   int CurrentLevel;                 // Current menu level (0=no menus active)
  210.   int NumberOfMenus;                // Number of menus available
  211.   int MouseInControl;               // Is mouse in control of menu (1) or
  212.                                     // not (0).  If not, callback will bring
  213.                                     // mouse control back.
  214.  
  215.   void SubMenu();
  216.   void CallMenu();
  217.   void FindNext();
  218.   void FindLast();
  219.   void BlankLine();
  220.   void EndSubMenu();
  221.   void RemoveMenu();
  222.   void RemoveOption();
  223.   void RefreshMenus();
  224.   void RemoveAllMenus();
  225.   void Available(int &);
  226.   void CheckMark(int &);
  227.   void PlaceOption(int);
  228.   void HotKey(char *,int);
  229.   void Selectable(int & ...);
  230.   void PlaceMenu(MenuItems &);
  231.   void NewMenu(char *,char *,int,int=0);
  232.   void Option(char *,char *,int=0,char *HotKey=0,int=0);
  233.  
  234.   int SetMenuBar(int,int,int,void far *Memory=0);
  235.  
  236.   static void MenuPopDown();
  237.   static void MenuPullDown();
  238.   static void SubMenuRight();
  239.   static void SubMenuBeneath();
  240.  
  241.   int Manager(int,int,int,WindowElement &,FusionWindow &);
  242.  
  243.   MenuManager();
  244.   ~MenuManager();
  245. };
  246.  
  247. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
  248. //                                                                           //
  249. // MenuAlteration - Menu alteration class                                    //
  250. //                                                                           //
  251. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
  252.  
  253. class MenuAlteration : public MenuManager
  254. {
  255. private:
  256.  
  257.   MenuItems *GrabThis(int,MenuItems *);
  258.  
  259. protected:
  260.  
  261.   void SetMenus();
  262.  
  263.   void DeleteLastMenu();
  264.   void DeleteAllMenus();
  265.   void DeleteMenu(int);
  266.   void DeleteOption(int);
  267.   void ChangeOption(int,char *,char *,int,char *,int);
  268. };
  269.  
  270. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
  271. //                                                                           //
  272. // FusionWindow - The main window and pulldown menu control class            //
  273. //                                                                           //
  274. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
  275.  
  276. class FusionWindow : public Event, public ShiftManager, public MenuAlteration
  277. {
  278. private:
  279.  
  280.   BlazeClass Blaze;                 // BlazeClass definition for windows
  281.  
  282.   WindowElement **Windows;          // Pointers to all available windows in
  283.                                     // the order in the reverse of which they
  284.                                     // are visible on the screen.  In other
  285.                                     // words, if there are two windows on
  286.                                     // the screen -- the window on top is
  287.                                     // the last window in this buffer.
  288.  
  289.   int MaxWindows;                   // Maximum open windows.  0 means keep
  290.                                     // opening until memory runs out, any
  291.                                     // other number specifies maximum windows
  292.  
  293.   int VirtualizeInterval;           // Time between virtual events
  294.  
  295.   int DefaultHelp;                  // This is the default help screen
  296.  
  297.   int CheckMoveOrSize();
  298.   void CallWindow(int);
  299.  
  300. protected:
  301.  
  302.   int CheckEcho();
  303.   int CheckVirtuals();
  304.   int CheckForEcho(int);
  305.  
  306.   void MoveWindow();
  307.   void SizeWindow();
  308.   void NextWindow();
  309.   void LastWindow();
  310.   void ZoomWindow();
  311.   void TileWindows();
  312.   void CloseWindow();
  313.   void CloseEcho(int);
  314.   void FreshEcho(int);
  315.   void StackWindows();
  316.   void ListAndSelect();
  317.   void CascadeWindows();
  318.   void RefreshWindows();
  319.   void PyramidWindows();
  320.   void VirtualizeFresh();
  321.   void IndexCardWindows();
  322.   void WaterFallWindows();
  323.   void RefreshWorkSpace();
  324.  
  325.   WindowElement *TopWindow();
  326.  
  327. public:
  328.  
  329.   int NumberOfWindows;              // Number of available windows
  330.  
  331.   FusionWindow();
  332.   virtual ~FusionWindow();
  333.  
  334.   int EngageFusion();
  335.   int NewWindow(WindowElement *,char *,int=0);
  336.   void GlobalHelp(int HelpSys) { DefaultHelp=HelpSys; }
  337.   void MaximumWindows(int Windows) { MaxWindows=Windows; }
  338.   void VirtualInterval(int);
  339.  
  340.   virtual int EventHandler(int) = 0;
  341.  
  342.   friend class WindowElement;
  343. };
  344.  
  345. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
  346. //                                                                           //
  347. // WindowColors - The colors for the defined window                          //
  348. // WindowElement - The window definition class                               //
  349. //                                                                           //
  350. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
  351.  
  352. class WindowColors
  353. {
  354. public:
  355.  
  356.   int WinBorder;                    // Window colors
  357.   int WinIcons;                     // See documentation for details
  358.   int WinTitle;
  359.   int WinScrollBar;
  360.   int WinSizeCorner;
  361.   int WinInterior;
  362.   int WinBoldInterior;
  363.   int WinAltInterior;
  364.   int WinDead;
  365.  
  366.   WindowColors();
  367. };
  368.  
  369. class WindowElement : public ShiftManager, public MenuManager,
  370.   public WindowColors
  371. {
  372. protected:
  373.  
  374.   // Global Window Related Stuff ---------------------------------------------
  375.  
  376.   char *Title;                // What is the title of the window?
  377.  
  378.   int MinimumWidth;           // What is the minimum width of the window?
  379.   int MinimumHeight;          // What is the minimum height of the window?
  380.  
  381.   int X;                      // X Coordinate -- Where is the window?
  382.   int Y;                      // Y Coordinate -- Where is the window?
  383.  
  384.   int Width;                  // How wide is the window?
  385.   int Height;                 // How high is the window?
  386.  
  387.   int WindowNumber;           // Can be numbered from 1 - 10, for ALT key
  388.                               // access, otherwise must be selected by
  389.                               // jumping
  390.  
  391.   int Active;                 // Is window currently active?
  392.  
  393.   int VirtualUpdate;          // Is window virtually updated?
  394.  
  395.   BlazeClass Blaze;
  396.  
  397.   // Scroll Bar Related Stuff ------------------------------------------------
  398.  
  399.   int ExistXScrollBar;        // Is there a horizontal scroll bar?
  400.   int ExistYScrollBar;        // Is there a vertical scroll bar?
  401.  
  402.   int XMaximum;               // What is the hi-end of the X bar?
  403.   int XCurrent;               // Where is the thumb tab on the X bar?
  404.  
  405.   int YMaximum;               // What is the hi-end of the Y bar?
  406.   int YCurrent;               // Where is the thumb tab on the Y bar?
  407.  
  408.   // Icon Related Stuff ------------------------------------------------------
  409.  
  410.   int ZoomIcon;               // Does window have a zoom icon?
  411.   int CloseIcon;              // Does window have a close icon?
  412.   int SizeIcon;               // Does window have a size icon?
  413.   int Moveable;               // Is the window movable?
  414.  
  415.   int WindowZoomed;           // Has the window been zoomed?
  416.  
  417.   int OldX;                   // The "OLD" variables are set with
  418.   int OldY;                   // numbers to represent the state
  419.   int OldWidth;               // of the window before the last
  420.   int OldHeight;              // zoom operation;
  421.  
  422.   // Connects this class to the Fusion Windows system ------------------------
  423.  
  424.   FusionWindow *MainHandler;  // Makes connection to FusionWindow so
  425.                               // the window has control over the global
  426.                               // menus
  427.  
  428.   // Window/Menu Validation and Checking Functions ---------------------------
  429.  
  430.   int CheckScrollBar();
  431.   void DisplayScrollBar();
  432.   void RemoveTheMenus();
  433.  
  434. public:
  435.  
  436.   WindowElement();
  437.   virtual ~WindowElement();
  438.  
  439.   virtual int Echo();
  440.   virtual void Cursor();
  441.   virtual void ReAlign();
  442.   virtual void ShowWindow();
  443.  
  444.   virtual void ShowInterior() = 0;
  445.   virtual int EventHandler(int) = 0;
  446.  
  447.   friend class FusionWindow;
  448. };
  449.  
  450. #endif
  451.  
  452.